#include "filefilterdialog.h"
#include "ui_filefilterdialog.h"
#include "../CheckInfor/DataBase/keywordlib.h"
#include <QDesktopServices>

FileFilterDialog::FileFilterDialog(Yzty::ToolCode type,QWidget *parent) :
    QDialog(parent),
    ui(new Ui::FileFilterDialog)
{
    ui->setupUi(this);
    InitUi();

    for(int i=0;i<ui->tabWidget->count();i++)
        ui->tabWidget->setTabEnabled(i,true);

    if(type==Yzty::ToolCode::Email)
        ui->tabWidget->setTabEnabled(1,false);


    SetDefaultValue();
}

FileFilterDialog::~FileFilterDialog()
{
    delete ui;
}

void FileFilterDialog::InitUi()
{
    //类型检查设置
    this->_tab1_1g=new QButtonGroup(this);          //时间限制按钮组
    this->_tab1_1g->addButton(ui->notime_check,Yzty::TimeLimit::NoLimit);
    this->_tab1_1g->addButton(ui->createtime_radio,Yzty::TimeLimit::Create);
    this->_tab1_1g->addButton(ui->modifytime_radio,Yzty::TimeLimit::Modify);

    connect(ui->notime_check,&QCheckBox::clicked,this,&FileFilterDialog::Tab1_Group1_Click);
    connect(ui->createtime_radio,&QRadioButton::clicked,this,&FileFilterDialog::Tab1_Group1_Click);
    connect(ui->modifytime_radio,&QRadioButton::clicked,this,&FileFilterDialog::Tab1_Group1_Click);
    connect(ui->starttime_line,&QDateTimeEdit::dateTimeChanged,[this](const QDateTime& time){
       this->Tab1_FileTimeLimit_Line(0,time);
    });
    connect(ui->endtime_line,&QDateTimeEdit::dateTimeChanged,[this](const QDateTime& time){
       this->Tab1_FileTimeLimit_Line(1,time);
    });

    this->_tab1_2g=new QButtonGroup(this);          //检查策略按钮组
    this->_tab1_2g->addButton(ui->wholecontent_radio,Yzty::FileCheckMethod::FILECONTENT);
    this->_tab1_2g->addButton(ui->forwardfile_radio,Yzty::FileCheckMethod::FORWARDCONTENT);

    connect(ui->wholecontent_radio,&QRadioButton::clicked,this,&FileFilterDialog::Tab1_Group2_Click);
    connect(ui->forwardfile_radio,&QRadioButton::clicked,this,&FileFilterDialog::Tab1_Group2_Click);
    //connect(ui->words_line,QOverload<int>::of(&QSpinBox::valueChanged),this,&FileFilterDialog::Tab1_FileCheckMethod_Line);


    this->_tab1_3g=new QButtonGroup(this);          //文件大小限制
    this->_tab1_3g->addButton(ui->nosizelimit_check,Yzty::SizeLimit::NoLimit);
    this->_tab1_3g->addButton(ui->sizelimit_check,Yzty::SizeLimit::Size);

    connect(ui->nosizelimit_check,&QCheckBox::clicked,this,&FileFilterDialog::Tab1_Group3_Click);
    connect(ui->sizelimit_check,&QCheckBox::clicked,this,&FileFilterDialog::Tab1_Group3_Click);
    connect(ui->minfilesize_line,QOverload<int>::of(&QSpinBox::valueChanged),[this](int size){
       this->Tab1_FileSizeLimit_Line(0,size);
    });
    connect(ui->maxfilesize_line,QOverload<int>::of(&QSpinBox::valueChanged),[this](int size){
       this->Tab1_FileSizeLimit_Line(1,size);
    });

    this->_pathmodel=new QStandardItemModel(this);
    this->_pathmodel->setHorizontalHeaderLabels({"路径"});
    ui->path_view->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中模式为选中行
    ui->path_view->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑
    ui->path_view->setModel(_pathmodel);
    this->_tab1_4g=new QButtonGroup(this);              //路径限制
    this->_tab1_4g->addButton(ui->system_check,0);      //默认系统分区
    this->_tab1_4g->addButton(ui->unsystem_check,1);    //非系统分区
//    ui->path_view->verticalHeader()->hide();            //隐藏行号


    ui->path_view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    connect(ui->system_check,&QCheckBox::clicked,this,&FileFilterDialog::Tab1_Group4_Click);
    connect(ui->unsystem_check,&QCheckBox::clicked,this,&FileFilterDialog::Tab1_Group4_Click);
    connect(ui->seepath_button,&QPushButton::clicked,this,&FileFilterDialog::SeePath_Button_Click);
    connect(ui->addpath_button,&QPushButton::clicked,this,&FileFilterDialog::AddPath_Button_Click);
    connect(ui->delete_path,&QPushButton::clicked,this,&FileFilterDialog::DeletePath_Button_Click);

    //文件检查类型
    connect(ui->microsoft_check,&QCheckBox::clicked,[this](){
        this->Tab2_FileTypeSelect(0);
    });

    connect(ui->jinshan_check,&QCheckBox::clicked,[this](){
       this->Tab2_FileTypeSelect(1);
    });

    connect(ui->openoffice_check,&QCheckBox::clicked,[this](){
        this->Tab2_FileTypeSelect(2);
    });

    connect(ui->other_check,&QCheckBox::clicked,[this](){
        this->Tab2_FileTypeSelect(3);
    });

    connect(ui->image_check,&QCheckBox::clicked,[this](){
       this->Tab2_FileTypeSelect(4);
    });

    //关键词配置
    this->_keywordmodel=new QStandardItemModel(this);
    this->_keywordmodel->setHorizontalHeaderLabels({"词库编号","词库","内容","检索方式"});
    ui->keywor_view->setSelectionBehavior(QAbstractItemView::SelectRows);//设置选中模式为选中行
    ui->keywor_view->setEditTriggers(QAbstractItemView::NoEditTriggers);//设置不可编辑
    ui->keywor_view->setModel(_pathmodel);
    ui->keywor_view->setModel(_keywordmodel);
    ui->keywor_view->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
    connect(ui->keyword_load_button,&QPushButton::clicked,this,&FileFilterDialog::LoadKeyWordLib_Button_Click);
    connect(ui->keyword_delete_button,&QPushButton::clicked,this,&FileFilterDialog::Deletewordlib_Button_Click);
    connect(ui->keyword_define_button,&QPushButton::clicked,this,&FileFilterDialog::DefineWordLib_Button_Click);

    //
    this->_micro=QVector<QCheckBox*>{
            ui->micro_doc_check,ui->micro_dot_check,ui->micro_excel_check,
            ui->micro_ppt_check,ui->micro_rtf_check,ui->micro_txt_check
    };

    this->_jinsan=QVector<QCheckBox*>{
            ui->jinshan_wps_check,ui->jinshan_et_check,ui->jinshan_dps_check
    };

    this->_openoffice=QVector<QCheckBox*>{
            ui->openoffice_type_check
    };

    this->_otheroffice=QVector<QCheckBox*>{
        ui->other_web_check,/*ui->other_zip_check*/ui->pdf_check
    };

    this->_image=QVector<QCheckBox*>{
            ui->image_bmp_check,ui->image_jpg_check,ui->image_pig_check,
            ui->image_png_check,ui->image_psd_check,ui->image_raw_check
    };


    QVariant* tp1=new QVariant(Yzty::FileTypeLimit::DOC|Yzty::FileTypeLimit::DOCX);
    ui->micro_doc_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::TEXT);
    ui->micro_txt_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::XLS|Yzty::FileTypeLimit::XLSX);
    ui->micro_excel_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::PPT|Yzty::FileTypeLimit::PPTX);
    ui->micro_ppt_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::WPS);
    ui->jinshan_wps_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::ET);
    ui->jinshan_et_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::DPS);
    ui->jinshan_dps_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::ODT|Yzty::FileTypeLimit::ODS|Yzty::FileTypeLimit::ODP);
    ui->openoffice_type_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::HTML|Yzty::FileTypeLimit::XML);
    ui->other_web_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::PNG);
    ui->image_png_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::JPG);
    ui->image_jpg_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::BMP);
    ui->image_bmp_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::PDF);
    ui->pdf_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::RTF);
    ui->micro_rtf_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::DOT);
    ui->micro_dot_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::PIG);
    ui->image_pig_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::PSD);
    ui->image_psd_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));

    tp1=new QVariant(Yzty::FileTypeLimit::RAW);
    ui->image_raw_check->setUserData(0,reinterpret_cast<QObjectUserData*>(tp1));



    //d
    connect(ui->startcheck_button,&QPushButton::clicked,this,&FileFilterDialog::StartCheck_Button_Click);
    connect(ui->canclecheck_button,&QPushButton::clicked,this,&FileFilterDialog::CancleCheck_Button_Click);

    this->_kdialog=new KeyWordDialog(this);
}

void FileFilterDialog::SetPath_Default()
{//添加用户主目录作为默认文件检查目录
    QFileInfo dir=QDir::homePath();
//    QFileInfo dir("/home/xingqincao/Documents/测试");
    QStandardItem* item=new QStandardItem(dir.filePath());
    this->_pathmodel->appendRow(QList<QStandardItem*>{item});
}

void FileFilterDialog::SetDefaultValue()
{
    //默认值设置
    ui->tabWidget->setCurrentIndex(0);
    ui->notime_check->setCheckState(Qt::CheckState::Checked);
//    ui->starttime_line->setDateTime(QDateTime::currentDateTime());
//    ui->endtime_line->setDateTime(QDateTime::currentDateTime());
    ui->starttime_line->setEnabled(false);
    ui->endtime_line->setEnabled(false);

    ui->filecontent_check->setCheckState(Qt::CheckState::Checked);
    ui->wholecontent_radio->setChecked(true);
    ui->words_line->setEnabled(false);

    ui->nosizelimit_check->setCheckState(Qt::CheckState::Checked);
    ui->minfilesize_line->setEnabled(false);
    ui->maxfilesize_line->setEnabled(false);

    ui->unsystem_check->setCheckState(Qt::CheckState::Checked);
//    ui->seepath_button->setEnabled(false);
//    ui->addpath_button->setEnabled(false);
//    ui->delete_path->setEnabled(false);
    this->_pathmodel->clear();
    this->_pathmodel->setHorizontalHeaderLabels({"路径"});
    this->_keywordmodel->clear();
    this->_keywordmodel->setHorizontalHeaderLabels({"词库编号","词库","内容","检索方式"});

    ui->microsoft_check->setCheckState(Qt::Checked);
    for(QCheckBox* box:_micro){
        box->setCheckState(Qt::CheckState::Checked);
        box->setEnabled(false);
    }

    ui->jinshan_check->setCheckState(Qt::Checked);
    for(QCheckBox* box:_jinsan)
    {
        box->setCheckState(Qt::CheckState::Checked);
        box->setEnabled(false);
    }

    ui->openoffice_check->setCheckState(Qt::Unchecked);
    for(QCheckBox* box:_openoffice)
    {
        box->setEnabled(false);
        box->setCheckState(Qt::CheckState::Unchecked);
    }

    ui->other_check->setCheckState(Qt::Unchecked);
    for(QCheckBox* box:_otheroffice)
    {
        box->setEnabled(false);
        box->setCheckState(Qt::CheckState::Unchecked);
    }

    ui->image_check->setCheckState(Qt::Unchecked);
    for(QCheckBox* box:_image)
    {
        box->setEnabled(false);
        box->setCheckState(Qt::CheckState::Unchecked);
    }
    this->_filtercondition=Yzty::FileCheckCondition();
    this->_filtercondition._sizelimit._model=Yzty::SizeLimit::NoLimit;
    this->_filtercondition._timelimit._model=Yzty::TimeLimit::NoLimit;
    this->_filtercondition._typelimit._marks=0;
    this->_filtercondition._checkmethod._marks=Yzty::FileCheckMethod::FILECONTENT;
    this->_filtercondition._keywordlimit._marks=0;
    this->SetPath_Default();
    this->SetDefault_KeyWordLib();
}

void FileFilterDialog::Tab1_Group1_Click()
{
    switch (_tab1_1g->checkedId())
    {
        case Yzty::TimeLimit::NoLimit:
            ui->starttime_line->setEnabled(false);
            ui->endtime_line->setEnabled(false);
            break;
        case Yzty::TimeLimit::Create:
            ui->starttime_line->setEnabled(true);
            ui->endtime_line->setEnabled(true);
            break;
        case Yzty::TimeLimit::Modify:
            ui->starttime_line->setEnabled(true);
            ui->endtime_line->setEnabled(true);
            break;
    }
}

void FileFilterDialog::Tab1_Group2_Click()
{
    switch(_tab1_2g->checkedId())
    {
        case Yzty::FileCheckMethod::FILECONTENT:
            ui->words_line->setEnabled(false);
            break;
        case Yzty::FileCheckMethod::FORWARDCONTENT:
            ui->words_line->setEnabled(true);
            break;
    }
}

void FileFilterDialog::Tab1_Group3_Click()
{
    switch (_tab1_3g->checkedId())
    {
        case Yzty::SizeLimit::NoLimit:
            ui->minfilesize_line->setEnabled(false);
            ui->maxfilesize_line->setEnabled(false);
            break;
        case Yzty::SizeLimit::Size:
            ui->minfilesize_line->setEnabled(true);
            ui->maxfilesize_line->setEnabled(true);
            break;
    }
}

void FileFilterDialog::Tab1_Group4_Click()
{
    switch (_tab1_4g->checkedId())
    {
        case 0:
            ui->seepath_button->setEnabled(false);
            ui->addpath_button->setEnabled(false);
            ui->delete_path->setEnabled(false);
            break;

        case 1:
            ui->seepath_button->setEnabled(true);
            ui->addpath_button->setEnabled(true);
            ui->delete_path->setEnabled(true);
            break;
    }
}

void FileFilterDialog::Tab1_FileTimeLimit_Line(int flag,const QDateTime& time)
{

    if((flag&&time<ui->starttime_line->dateTime())||
            (!flag&&time>ui->endtime_line->dateTime()))
    {
        QMessageBox::warning(this,"warning","时间范围错误");
        if(flag)    ui->starttime_line->setDateTime(ui->endtime_line->dateTime());
        else        ui->endtime_line->setDateTime(ui->starttime_line->dateTime());
    }

}

void FileFilterDialog::Tab1_FileSizeLimit_Line(int flag,int size)
{
    if((flag&&size<ui->minfilesize_line->value())||
            (!flag&&size>ui->maxfilesize_line->value()))
    {
        QMessageBox::warning(this,"warning","文件大小范围错误");
        if(flag)    ui->maxfilesize_line->setValue(ui->minfilesize_line->value());
        else        ui->minfilesize_line->setValue(ui->maxfilesize_line->value());
    }
}

void FileFilterDialog::Tab2_FileTypeSelect(int flag)
{
    Qt::CheckState state=Qt::CheckState::Checked;
    switch (flag)
    {
        case 0:
            state=ui->microsoft_check->checkState();
            break;
        case 1:
            state=ui->jinshan_check->checkState();
            break;
        case 2:
            state=ui->openoffice_check->checkState();
            break;
        case 3:
            state=ui->other_check->checkState();
            break;
        case 4:
            state=ui->image_check->checkState();
            break;
    }

    switch (flag)
    {
        case 0:
            for(QCheckBox* box:_micro)
            {
                if(state==Qt::CheckState::Unchecked)
                    box->setEnabled(false);
                else
                    box->setEnabled(true);
                box->setCheckState(state);
            }
            break;
        case 1:
            for(QCheckBox* box:_jinsan)
            {
                if(state==Qt::CheckState::Unchecked)
                    box->setEnabled(false);
                else
                    box->setEnabled(true);
                box->setCheckState(state);
            }
            break;
        case 2:
            for(QCheckBox* box:_openoffice)
            {
                if(state==Qt::CheckState::Unchecked)
                    box->setEnabled(false);
                else
                    box->setEnabled(true);
                box->setCheckState(state);
            }
            break;
        case 3:
            for(QCheckBox* box:_otheroffice)
            {
                if(state==Qt::CheckState::Unchecked)
                    box->setEnabled(false);
                else
                    box->setEnabled(true);
                box->setCheckState(state);
            }
            break;
        case 4:
            for(QCheckBox* box:_image)
            {
                if(state==Qt::CheckState::Unchecked)
                    box->setEnabled(false);
                else
                    box->setEnabled(true);
                box->setCheckState(state);
            }
            break;
    }

}

void FileFilterDialog::SeePath_Button_Click()
{
    QString dir=QFileDialog::getExistingDirectory(this,"path",QDir::currentPath());

    if(dir.isEmpty())
        return;

    //应该排除重复路径
    //添加路径
    ui->showpath_line->setText(dir);
}


void FileFilterDialog::AddPath_Button_Click()
{
    QFileInfo dir=QFileInfo(ui->showpath_line->text());

    if(!dir.isDir())
    {
        QMessageBox::warning(this,"error","路劲不合法");
        return;
    }
    QStandardItem* item=new QStandardItem(dir.filePath());
    this->_pathmodel->appendRow(QList<QStandardItem*>{item});
}

void FileFilterDialog::DeletePath_Button_Click()
{
   int r=ui->path_view->currentIndex().row();

   if(r<0||r>=_pathmodel->rowCount())
       return;

   this->_pathmodel->removeRow(r);
}

void FileFilterDialog::StartCheck_Button_Click()
{
    //时间
    if(_tab1_1g->checkedId()!=Yzty::TimeLimit::NoLimit)
    {
        _filtercondition._timelimit._model=uint16_t(_tab1_1g->checkedId());
        if(_tab1_1g->checkedId()==Yzty::TimeLimit::Create)
        {
            _filtercondition._timelimit._start_create_time=ui->starttime_line->dateTime();
            _filtercondition._timelimit._end_create_time=ui->endtime_line->dateTime();
        }else if(_tab1_2g->checkedId()==Yzty::TimeLimit::Create)
        {
            _filtercondition._timelimit._start_modify_time=ui->starttime_line->dateTime();
            _filtercondition._timelimit._end_modify_time=ui->endtime_line->dateTime();
        }

    }

    //策略
    _filtercondition._checkmethod._marks=uint16_t(_tab1_2g->checkedId());
    if(ui->filename_check->isChecked())
        _filtercondition._checkmethod._marks|=uint16_t(Yzty::FileCheckMethod::FILENAME);
    if(_tab1_2g->checkedId()==Yzty::FileCheckMethod::FORWARDCONTENT)
        _filtercondition._checkmethod._wordlimits=uint32_t(ui->words_line->value());

    //大小
    if(_tab1_3g->checkedId()==Yzty::SizeLimit::Size)
    {
        _filtercondition._sizelimit._model=Yzty::SizeLimit::Size;
        _filtercondition._sizelimit._lowlimit=uint32_t(ui->minfilesize_line->value());
        _filtercondition._sizelimit._uplimit=uint32_t(ui->maxfilesize_line->value());
    }

    //位置
    if(_tab1_4g->checkedId()==0)
    {
        _filtercondition._dirlimit._dirs.append(QDir("/sys"));  //系统路径
    }else
    {
        for(int i=0;i<this->_pathmodel->rowCount();++i)
        {
            _filtercondition._dirlimit._dirs.append(QDir(_pathmodel->index(i,0).data().toString()));    //加入选定路径
        }
    }

    //关键词
    for(int i=0;i<this->_keywordmodel->rowCount();++i)
    {
        Yzty::WordLibCode code=_keywordmodel->index(i,0).data().toLongLong();
        Yzty::WordCheckMethod method=Yzty::WordCheckMethod(_keywordmodel->index(i,3).data(Qt::UserRole).toInt());
        _filtercondition._keywordlimit._marks|=code;
        _filtercondition._keywordlimit._methods[code]=method;
    }

    //类型
    for(QCheckBox* box:_micro)
    {
        if(box->isChecked())
        {
            quint64 t=((reinterpret_cast<QVariant*>(box->userData(0)))->toULongLong());
            this->_filtercondition._typelimit._marks+=t;
        }
    }

    for(QCheckBox* box:_jinsan)
    {
        if(box->isChecked())
        {
            quint64 t=((reinterpret_cast<QVariant*>(box->userData(0)))->toULongLong());
            this->_filtercondition._typelimit._marks+=t;
        }
    }

    for(QCheckBox* box:_openoffice)
    {
        if(box->isChecked())
        {
            quint64 t=((reinterpret_cast<QVariant*>(box->userData(0)))->toULongLong());
            this->_filtercondition._typelimit._marks+=t;
        }
    }

    for(QCheckBox* box:_otheroffice)
    {
        if(box->isChecked())
        {
            quint64 t=((reinterpret_cast<QVariant*>(box->userData(0)))->toULongLong());
     //   quint64 t=((reinterpret_cast<QVariant*>(box->property()))->toULongLong());
            this->_filtercondition._typelimit._marks+=t;
        }
    }

    for(QCheckBox* box:_image)
    {
        if(box->isChecked())
        {
            quint64 t=((reinterpret_cast<QVariant*>(box->userData(0)))->toULongLong());
            this->_filtercondition._typelimit._marks+=t;
        }
    }


    accept();
}

void FileFilterDialog::CancleCheck_Button_Click()
{
   reject();
}


void FileFilterDialog::SetDefault_KeyWordLib()
{
     Yzty::KeyWordLimit temp;
     temp._marks=2;
     QList<QStandardItem*> items;
     QStandardItem* item=nullptr;
     item=new QStandardItem(QString::number(temp._marks));
     items.push_back(item);
     item=new QStandardItem(KeyWordLib::GetInstance()->GetLibName(temp._marks));
     items.push_back(item);
     QString t=QStringList(KeyWordLib::GetInstance()->GetWordList(temp._marks).toList()).join('|');
     item=new QStandardItem(t);
     items.push_back(item);
     item=new QStandardItem;
     t="包含任意单词";
     item->setData(int(Yzty::WordCheckMethod::ALLWORD),Qt::UserRole);
     item->setText(t);
     items.push_back(item);
     this->_keywordmodel->appendRow(items);
}

void FileFilterDialog::LoadKeyWordLib_Button_Click()
{
    int ret=this->_kdialog->exec();
    if(ret==1)
    {
        auto temp=this->_kdialog->GetKeyWordInfor();

        for(int i=0;i<63;++i)
        {
            if((temp._marks>>i)&1)
            {
                QList<QStandardItem*> items;

                QStandardItem* item=nullptr;
                item=new QStandardItem(QString::number(1<<i));
                items.push_back(item);

                item=new QStandardItem(KeyWordLib::GetInstance()->GetLibName(1<<i));
                items.push_back(item);

                QString t=QStringList(KeyWordLib::GetInstance()->GetWordList(1<<i).toList()).join('|');
                item=new QStandardItem(t);
                items.push_back(item);

                item=new QStandardItem;
                if(temp._methods[1<<i]==Yzty::WordCheckMethod::ALLWORD)
                {
                    t="包含全部单词";
                    item->setData(int(Yzty::WordCheckMethod::ALLWORD),Qt::UserRole);
                }
                else if(temp._methods[1<<i]==Yzty::WordCheckMethod::ANYWORD)
                {
                    t="包含任意单词";
                    item->setData(int(Yzty::WordCheckMethod::ANYWORD),Qt::UserRole);
                }
                else
                {
                    t="不包含任意单词";
                    item->setData(int(Yzty::WordCheckMethod::NOANYWORD),Qt::UserRole);
                }
                item->setText(t);
                items.push_back(item);
                this->_keywordmodel->appendRow(items);
            }
        }
    }
}

void FileFilterDialog::Deletewordlib_Button_Click()
{

}

void FileFilterDialog::DefineWordLib_Button_Click()
{

}

int FileFilterDialog::exec()
{
    SetDefaultValue();
    int ret=QDialog::exec();
    return ret;
}

Yzty::FileCheckCondition FileFilterDialog::GetFilterCondition()
{
    return this->_filtercondition;
}
